<%@ page pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
	<title>修改用户</title>
</head>
<body>
	<h3>修改用户</h3>
<div style = "background: url(../images/menuBg.png) repeat fixed; height:420px">
	<form id="form">
		<input type="hidden" name="id" value="${user.id}"/>
		<input type="hidden" name=jobNumber value="${user.jobNumber}"/>
		<div class="content_row">
			<span class="row"><label><font color ="red">*</font>&nbsp;用户名</label>
			<input type="text" name="username" id="username" value="${user.username}"/></span>
			<span class="row"><label><font color ="red">*</font>&nbsp;姓名</label>
			<input type="text" name="name" id="name" value="${user.name}"/></span>
			<span class="row"><label><font color ="red">*</font>&nbsp;部门</label>
			<input type="text" id="deptId" name="deptId" style="width:144px"/></span>
		</div>
		<div class="content_row">
			<span class="row"><label><font color ="red">*</font>&nbsp;电话</label>
			<input type="text" name="telephone" id="telephone" value="${user.telephone}"/></span>
			<span class="row"><label><font color ="red">*</font>&nbsp;邮箱</label>
			<input type="text" name="email" id="email" value="${user.email}"/></span>
			<span class="row"><label><font color ="red">*</font>&nbsp;角色</label>
			<input id="roleId" class="easyui-combobox" name="roleId" value="${role.roleId}" data-options="valueField:'id',textField:'name',url:'/user/listAllSysrole.do'" style="width:144px"></span>
		</div>
		<div class="content_row">
			<span class="row"><label><font color ="red">*</font>&nbsp;是否是管理者</label>
				<select id="ismanager" style="width: 144px;" class="easyui-combobox" name="ismanager">
					<option value ="">请选择</option>
				    <option value ="否">否</option>
				    <option value ="是">是</option>
				</select>
			</span>
		<!-- <span class="row"><label>密码</label><input type="password" name="password" value="${user.password}"/></span> -->
		</div>
		<div class="content_row content_row_btn">
			<a href="javascript:void(0)" onclick="infoVal();" class="commonbtn">保存</a>
			<a href="javascript:void(0)" onclick="openUrl('/user/listUserView.do');" class="commonbtn">返回</a>
		</div>
	</form>
</div>
<script type="text/javascript">
	$(function(){
		$('#deptId').combotree({
		    url: '/user/getDeptTree.do',
		    onLoadSuccess:function(){
		    	$('#deptId').combotree('setValue', '${user.deptId}');
		    }
		});
		
		setTimeout(function(){
			$('#ismanager').combobox('setValue', '${user.ismanager}');
		},200);
	});
	
	//校验表单必填项
	function infoVal(){
		
		var username = $("#username").val();
		if($.trim(username)==""){
			$.messager.alert('提示', '请输入【用户名】！','info');
			return false;
		}
		
		var name = $("#name").val();
		if($.trim(name)==""){
			$.messager.alert('提示', '请输入【姓名】！','info');
			return false;
		}
		
		var deptId = $("#deptId").combobox('getValue');
		if($.trim(deptId)=="0"){
			$.messager.alert('提示', '请输入【部门】！','info');
			return false;
		}
		
		var ismanager = $("#ismanager").combobox('getValue');
		if($.trim(ismanager)==""){
			$.messager.alert('提示', '请输入【是否管理者】！','info');
			return false;
		}
		
		var telephone = $("#telephone").val();
		if($.trim(telephone)==""){
			$.messager.alert('提示', '请输入【电话】！','info');
			return false;
		}
		
		var email = $("#email").val();
		if($.trim(email)==""){
			$.messager.alert('提示', '请输入【邮箱】！','info');
			return false;
		}
		
		var roleId = $("#roleId").combobox('getValue');
		if($.trim(roleId)==""){
			$.messager.alert('提示', '请输入【角色】！','info');
			return false;
		}
		
		submitForm('/user/updateUser.do','/user/listUserView.do');
	}
</script>
</body>
</html>
